<template>
  <div>
    <van-dropdown-menu>
      <van-dropdown-item
        v-model="value1"
        :options="option1"
        title="综合"
        disabled
      />
      <van-dropdown-item
        v-model="value1"
        :options="option1"
        title="价格"
        @change="jiagechange"
      />
      <van-dropdown-item
        v-model="value2"
        :options="filterCategory"
        title="分类"
        @change="categoryChange"
      />
    </van-dropdown-menu>
    <!-- 如果没有产品,products就不展示,而要展示Empty组件 -->
    <van-empty
      v-if="productsListData.length == 0"
      description="没有你想找的商品,你去别人家看看把,嘻嘻"
    />
    <Products v-else :productsListData="productsListData"></Products>
  </div>
</template>

<script>
import Products from "../Products.vue";
export default {
  components: {
    Products,
  },
  props: ["productsListData", "filterCategory"],
  data() {
    return {
      value1: "",
      value2: "a",
      option1: [
        { text: "价格由高到低", value: "desc" },
        { text: "价格由低到高", value: "asc" },
      ],
      // option2: [
      //   { text: "全部", value: "a" },
      //   { text: "居家", value: "b" },
      // ],
    };
  },
  beforeUpdate() {
    this.filterCategory.map((item) => {
      if (item.checked) {
        this.value2 = item.value;
      }
    });
  },
  methods: {
    categoryChange(value) {
      console.log("选中了", value);
      console.log(this.filterCategory);
      this.$emit("categoryChangefenlei", value);
    },
    jiagechange(value) {
      this.$emit("jiagedepaixu", value);
    },
  },
};
</script>
 
<style lang = "less" scoped>
</style>